define(function (require, exports, module) {
	var HandlerBars = require("handlebars");
	var orderConfirmTpl = require("../assets/tpl/order_confirm.tpl");
	var cartEvents = require("../handler/cartEvents");
	var productDetails = require("./productDetails");
	
    var instance = {
    	//显示订单确认页面
        showOrderConfirm: function (widget) {
        	widget.hide(["#homeMenu","#home-center","#details-center","#details-return-home-menu","#cart","#shooping-cart","#goSettlement"])
        			.show(["#otherMenu","#order-confirm-menu","#order-confirm-center","#settlement","#return-home-menu"]);
        	var cartData = localStorage.getItem("cartData");
   			cartData = cartData?JSON.parse(cartData):{};
        	cartEvents.updateOrderConfirmDom(widget,cartData);
        },
        //从订单返回主页
        returnHome:function(widget){
        	widget.show(["#homeMenu","#home-center","#cart","#shooping-cart","#goSettlement"])
				.hide(["#otherMenu","#order-confirm-menu","#order-confirm-center","#settlement","#return-home-menu",
				       "#change-pay-type-menu","#change-pay-center","#orderPay","#return-order-menu"]);
        	
        	
        },
        //显示选择支付方式页面
        showChangePayType: function (widget) {
        	widget.hide(["#homeMenu","#home-center","#details-center","#details-return-home-menu","#cart","#shooping-cart","#goSettlement","#return-home-menu"])
				.show(["#otherMenu","#change-pay-type-menu","#change-pay-center","#orderPay"]);
        	$("#cardNumber").focus();
        	
        },
        //从支付返回订单
        returnChangePayType:function(widget){
        	widget.show(["#order-confirm-center","#order-confirm-menu","#settlement","#return-home-menu"])
				.hide(["#change-pay-type-menu","#change-pay-center","#orderPay","#return-order-menu"]);
        },
        //显示支付成功页面
        showPaySuccess: function (widget) {
        	widget.hide(["#change-pay-center","#change-pay-type-menu","#orderPay","#total-price-but","#return-order-menu",".J-fooder"])
				.show(["#otherMenu","#pay-success-menu","#pay-success-center"]);
        	var that = this;
        	setTimeout(function(){
        		that.returnHomeByButton(widget)
        	},3000);
        },
        showDetails:function(widget,data){
        	widget.hide(["#homeMenu","#home-center"])
				.show(["#otherMenu","#details-return-home-menu","#details-center"]);
        	
        	productDetails.initDetails(widget,data);
        	
        },
        returnHomeByDetails:function(widget){
        	widget.show(["#homeMenu","#home-center"])
				.hide(["#otherMenu","#details-return-home-menu","#details-center"]);
        },
        //从支付成功返回首页
        returnHomeByButton:function(widget){
        	widget.show([".J-fooder","#homeMenu","#home-center","#cart","#shooping-cart","#goSettlement","#total-price-but"])
        	.hide(["#pay-success-center","#pay-success-menu","#otherMenu"]);
        	cartEvents.removeAll(widget);
        }
    };
    module.exports = instance;
});
